<!doctype html>
<html lang="en">
 <head>
  <meta charset="UTF-8">
  <meta name="Generator" content="EditPlus®">
  <meta name="Author" content="">
  <meta name="Keywords" content="">
  <meta name="Description" content="">
  <title>Document</title>
  <style>
     #div_1{
	    width:200px;
		height:200px;
		background-color:red;
	 }
	 #div_2{
	  width:200px;
		height:200px;
	    background-color:blue;
	 }
  </style>
 </head>
 <body>
     <div id="div_1"></div>
	 <button id="btn_1">变色</button>
	 <button id="btn_2">右移</button>
 </body>
 <script>
     var div = document.getElementById("div_1");
	 var btn_1 = document.getElementById("btn_1");
	 var btn_2 = document.getElementById("btn_2");
	 var left = 20;
	 btn_1.addEventListener("click",function(){
		 if(div.style.backgroundColor == ""){
		    div.style.backgroundColor = "blue";
		 }else if(div.style.backgroundColor == "blue"){
			 
		    div.style.backgroundColor = "red";
		 }else{
		   div.style.backgroundColor = "blue";
		 }
	 })
	 btn_2.addEventListener("click",function(){
		 div.style.marginLeft = left+"px";
		 left = left + 20;
	 })
 </script>
</html>
